home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 11
/
Cream of the Crop 11-1.iso
/
games
/
dcgames4.zip
/
CURRITEM.SCR
< prev
next >
Wrap
Text File
|
1995-10-02
|
41KB
|
1,228 lines
!
! Script Name: CURRITEM.SCR
!
! This script may be called by any script (using 'runscript') to handle
! actions on objects pointed to by the generic CURRITEM object, which
! may point to any object being carried by a player or NPC character
! in it's backpack (PLAYER.BP or NPC.PB) or being worn (or wielded)
! by the same (PLAYER.BODY, PLAYER.WEAPON, NPC.ARMOR, etc)
!
! You cannot make CURRITEM point to 'OBJECT' since the object is not
! being carried, so a different script of almost identical structure
! (called DESCOBJ.SCR) is available for looking at those.
!
! Before calling this script, you should make sure that the CURRITEM
! object is pointing to the right object. Examples follow:
!
! To 'look' at the weapon being worng by a player:
! curritem = player.weapon;
! runscript( player.weapon.script, "CURRITEM", LOOK );
!
! To 'examine' the currently selected backpack item in an NPC's backpack
! curritem = npc.bp;
! runscript( npc.bp.script, "CURRITEM", EXAMINE );
!
! To 'examine' the vehicle being used by the party,
! curritem = group.vehicle;
! runscript( group.vehicle.script, "CURRITEM", EXAMINE );
!
! To 'invoke' an scroll in the player's backpack, selecting the item
! from a menu of all scrolls being carried:
! L0 = select( player.bp, SCROLL );
! if L0 >= 0 then
! ! Note that 'curritem' was set by the select itself, so we don't
! ! have to assign 'curritem' at all.
! ! You could say 'curritem = player.bp' if you wanted to make
! ! it clear you expect curritem to be the currently selected backpack
! ! item.
! runscript( curritem.script, "CURRITEM", INVOKE );
! endif;
!
! Remember that the CURRITEM generic object is changed everytime you
! perform one of the following actions:
!
! ACTION CHANGES TO CURRITEM
! -------------------- -------------------------------------------
! vanish(NPC) if curritem belongs to NPC, it is left undefined
! curritem = x; Direct assignment to one of the following:
! group.vehicle
! npc.bp, npc.body, npc.weapon, ..
! player.bp, player.body, player.weapon, ..
! x = select( .. ) A menu selection from a player's or npc's
! bp or body set's curritem also!
!
!------------------------------------------------------------------------!
! :@TALK ! No talking in this script..
!------------------------------------------------------------------------!
! :@GET ! No getting in this script
!------------------------------------------------------------------------!
!------------------------------------------------------------------------!
:@DROP ! Drop the object on the floor !
!------------------------------------------------------------------------!
if curritem.count > 1 then
L(0) = getnum( "How many? ", 0, curritem.count );
if L(0) > 0 then
writeln( "You drop ", L(0), " ", curritem.name, "(s)" );
drop( curritem, L(0) );
else
writeln( "None." );
endif;
else
writeln( "You drop the ", curritem.name );
drop( curritem );
endif;
STOP;
!------------------------------------------------------------------------!
:@EXIT ! Exit a VEHICLE (since this is an object we are talking about..)
!------------------------------------------------------------------------!
! Since you can only ride one vehicle at a time, this portion of the
! script assumes you want to exit from the vehicle being ridden, so
! we ignore 'curritem' and use 'group.vehicle' directly.
if group.vehicle.count = 0 then
writeln("You are already on foot!" );
STOP;
endif;
drop( group.vehicle );
voice( "Exit", 1000 );
writeln( "You are now on foot.." );
STOP;
!------------------------------------------------------------------------!
:@WEAR ! Wearing or wielding stuff
!------------------------------------------------------------------------!
L(0) = 0; ! Hands needed to hold the item..
on curritem.type goto
WR_FOOD, WR_WEAPON, WR_AMMO, WR_ARMOR, WR_SHIELD,
WR_AMULET, WR_RING, WR_POTION, WR_SCROLL, WR_STAFF;
!
! the rest can't be worn, so no need to list them..
! WR_CHEST, WR_KEYS, WR_GEMS, WR_BOOK, WR_GOLDSACK,
! WR_TORCH, WR_LANTERN, WR_ROPE, WR_HOOKS, WR_MIRROR,
! WR_SIGN, WR_VEHICLE
!
:WR_FOOD
:WR_AMMO
:WR_POTION
:WR_SCROLL
writeln( "How do you wear a ", curritem.type, "? " );
STOP;
:WR_WEAPON
gosub STILLKICKING;
if (player.class = ELF or player.class = WIZARD or player.class = ARCHER)
and curritem.weight > 5 + adjustments(player.str) then
writeln( "This weapon is too heavy for this character class." );
elsif player.class = WIZARD and curritem.hands > 1 then
writeln( "Wizards can only use one-handed weapons" );
elsif (player.class = WIZARD or player.class = DWARF) and curritem.class = MISSILE then
writeln( "Wizards and dwarfs can't use non-magical missile weapons" );
elsif player.weapon.count > 0 then
writeln( "You must first remove the ", player.weapon.name );
else
L(0) = curritem.hands; ! Hands needed to hold the weapon !
S0 = "wielding";
goto WR_DOIT;
endif;
STOP;
:WR_ARMOR
gosub STILLKICKING;
if (player.class = ELF or player.class = WIZARD) and
curritem.weight > 5 + adjustments(player.str) then
writeln( "This armor is too heavy for an elf or a wizard" );
elsif player.class = ARCHER and
curritem.weight > 10 + adjustments(player.str) then
writeln( "This armor is too cumbersome for an archer" );
elsif player.armor.count > 0 then
writeln( "You must first remove the ", player.armor.name );
else
S0 = "wearing";
goto WR_DOIT;
endif;
STOP;
:WR_SHIELD
gosub STILLKICKING;
if player.class = WIZARD or player.class = ARCHER or player.class = DWARF then
writeln( player.class, "s cannot use a shield!" );
elsif player.class = ELF and curritem.weight > 5 + adjustments(player.str) then
writeln( "The shield is too heavy for an ELF." );
elsif player.shield.count > 0 then
writeln( "You must first remove the ", player.shield.name );
else
L(0) = 1; ! A shield always needs 1 hand.. !
S0 = "using";
goto WR_DOIT;
endif;
STOP;
:WR_STAFF
gosub STILLKICKING;
L(0) = 1; ! A staff always needs 1 hand.. !
if player.class = FIGHTER then
writeln( "Fighters can't use magic staffs." );
elsif curritem.charges = 0 then
writeln( "The staff has no charges left.." );
elsif player.staff.count > 0 then
writeln( "You must first remove the ", player.staff.name );
else
S0 = "holding";
goto WR_DOIT;
endif;
STOP;
:WR_AMULET
:WR_RING
if player.class = FIGHTER then
writeln( "Fighters can't use magic ", curritem.type, "s." );
elsif curritem.charges = 0 then
writeln( "The ", curritem.type, " has no charges left.." );
elsif curritem.type = AMULET and player.amulet.count > 0 then
writeln( "You must first remove the ", player.amulet.name );
elsif curritem.type = RING and player.ring.count > 0 then
writeln( "You must first remove the ", player.ring.name );
else
S0 = "wearing";
goto WR_DOIT;
endif;
STOP;
:WR_DOIT
L(1) = 2; ! Player has 2 hands.. !
if player.weapon.count then dec( L(1), player.weapon.hands ); endif;
if player.shield.count then dec( L(1), 1 ); endif;
if player.staff.count then dec( L(1), 1 ); endif;
if L(0) > L(1) then
writeln( "You don't have enough free hands!" );
STOP;
endif;
!
move( curritem, player.body, 1 );
if success then
writeln( "You are now ", s0, " the ", player.body.name );
if player.body.type = ARMOR or player.body.type = SHIELD then
if player.armor.cursed or player.shield.cursed then
player.ac = 0;
else
inc(player.ac,player.body.ac);
endif;
elsif player.body.type = RING or player.body.type = AMULET then
if( player.body.charges > 0 ) then
curritem = player.body;
gosub M1_INVOKE;
if curritem.charges < 255 then
dec( curritem.charges );
endif;
else
writeln( "The ", player.body.type, " has no charges." );
endif;
endif;
endif;
STOP;
!------------------------------------------------------------------------!
:@USE ! Use an object in our backpack...
!------------------------------------------------------------------------!
on curritem.type goto
USE_FOOD, USE_WEAPON, USE_AMMO, USE_ARMOR, USE_SHIELD,
USE_AMULET, USE_RING, USE_POTION, USE_SCROLL, USE_STAFF,
USE_CHEST, USE_KEYS, USE_GEMS, USE_BOOK, USE_GOLDSACK,
USE_TORCH, USE_LANTERN, USE_ROPE, USE_HOOKS, USE_MIRROR,
USE_SIGN, USE_VEHICLE, USE_DOOR, USE_THING;
:USE_THING
writeln( "I don't know what to do with the ", curritem.name );
STOP;
:USE_FOOD
:USE_POTION
:USE_GEMS
:USE_SCROLL
goto @INVOKE;
:USE_AMULET
:USE_RING
:USE_ARMOR
:USE_WEAPON
:USE_SHIELD
:USE_STAFF
goto @WEAR;
:USE_AMMO
writeln( "Just carry it in your backpack. If you 'wield' a " );
writeln( "weapon that uses this type of ammo, it will get used" );
writeln( "automaticly." );
STOP;
:USE_CHEST
! Unlock the chest !
if curritem.locktype then
gosub UNLOCK_OBJECT;
if curritem.locktype = 0 then
STOP;
endif;
writeln( "You don't have the right key! Break the lock?" );
L0 = select( "Yes", "No" );
if L0 = 0 then
if curritem.class <> NORMAL_CHEST then
writeln( "You can't break this kind of chest." );
elsif random( 2 + adjustments(player.str) ) > 0 then
write( "You broke the lock!" );
if curritem.traptype = 1 then
voice( "Argh", 1000 ); ! 1000 = DCSOUNDS.VFL !
writeln( "Argh.. Poison trap!" );
player.poisoned = 1;
elsif curritem.traptype > 1 then
voice( "Explode", 1000 ); ! Play standard sound effect !
writeln( "Bomb Trap!" );
dec( player.hp, curritem.damage );
if player.hp = 0 then
writeln( player.name, " has died.." );
endif;
endif;
curritem.locktype = 0;
if curritem.block2 then
curritem.block = curritem.block2;
endif;
else
writeln( "It doesn't break!" );
endif;
else
writeln( "Ok." );
endif;
stats(-1); ! Restore Statistics !
else
writeln( "It is not locked.." );
endif;
STOP;
:USE_KEYS
writeln( "All keys are checked when trying to open a door or chest," );
writeln( "you just have to carry it with you.." );
STOP;
:USE_BOOK
goto @LOOK;
:USE_GOLDSACK
L(1) = getnum("How many gold pieces do you want to put in it?",
0, group.gold / 10) * 10;
if L(1) then
writeln( "You put ", $L1, " in the bag." );
inc( curritem.value, L(1) );
dec( group.gold, L(1) );
else
writeln( "Ok.." );
endif;
STOP;
:USE_TORCH
:USE_LANTERN
writeln( "Save your torches.. I haven't implemented LIGHT yet!" );
STOP;
:USE_ROPE
writeln( "After fooling around with it for a while, you manage to" );
writeln( "get yourself tangled up..." );
STOP;
:USE_HOOKS
voice( "Ouch", 1000 );
writeln( "Ouch! (it's sharp!)" );
STOP;
:USE_MIRROR
writeln( "Yes, you are ugly, but that doesn't matter here.." );
STOP;
:USE_SIGN
writeln( "If you want to read it, put it back where you found it!" );
STOP;
:USE_VEHICLE
writeln( "It would be easyer if you put it down first!" );
STOP;
:USE_DOOR
writeln( "Why are you carrying a door?" );
STOP;
!------------------------------------------------------------------------!
:@REMOVE ! Remove an item being worn...
!------------------------------------------------------------------------!
if curritem.cursed then
writeln( "The ", curritem.type, " is cursed and cannot be removed.." );
STOP;
endif;
if player.hp = 0 then
writeln( player.name, " is dead." );
STOP;
endif;
if curritem.type = ARMOR or curritem.type = SHIELD then
if player.ac > curritem.ac then
dec(player.ac,curritem.ac);
else
player.ac = 0;
endif;
elsif curritem.type = RING or curritem.type = AMULET then
writeln("ITEM=",curritem.name," TYPE=", curritem.type, " P=", curritem.permanent );
if not curritem.permanent then
writeln( "CURRITEM.CLASS=",curritem.class," AC = ", PLUS_AC );
on curritem.class goto
XNON, XNON, XNON, XNON, XNON,
X_STR, X_DEX, X_SPD, X_AIM, X_AC, X_HP, X_IQ, X_PWR;
goto XNON;
:X_STR if player.str > curritem.units then
dec(player.str,curritem.units);
else
player.str = 0;
endif;
goto :XNON;
:X_DEX if player.DEX > curritem.units then
dec(player.DEX,curritem.units);
else
player.DEX = 0;
endif;
goto :XNON;
:X_SPD if player.SPD > curritem.units then
dec(player.SPD,curritem.units);
else
player.SPD = 0;
endif;
goto :XNON;
:X_AIM if player.AIM > curritem.units then
dec(player.AIM,curritem.units);
else
player.AIM = 0;
endif;
goto :XNON;
:X_AC if player.AC > curritem.units then
dec(player.AC,curritem.units);
else
player.AC = 0;
endif;
goto :XNON;
:X_HP if player.hp > player.mhp then
if player.hp - curritem.units > player.mhp then
dec(player.hp,curritem.units);
else
player.hp = player.mhp; ! No lower than regular max !
endif;
endif;
goto :XNON;
:X_IQ if player.IQ > curritem.units then
dec(player.IQ,curritem.units);
else
player.IQ = 0;
endif;
goto :XNON;
:X_PWR if player.PWR > curritem.units then
dec(player.PWR,curritem.units);
else
player.PWR = 0;
endif;
goto :XNON;
endif;
writeln( "BEFORE XNON");
:XNON
writeln( "AFTER XNON");
endif;
move( curritem, player.bp, 1 );
if failure then
writeln( "ERROR: Couldn't take off the ", curritem.name );
else
writeln( player.name, " takes off the ", player.bp.name );
endif;
STOP;
!------------------------------------------------------------------------!
:@LOOK ! Finally something we can do!!!!
!------------------------------------------------------------------------!
L(255) = FALSE; ! Set a flag so the subroutine does not give a
! full description (i.e. LOOK, not EXAMINE)
gosub DESCRIBE;
STOP;
!------------------------------------------------------------------------!
:@EXAMINE ! Examine the object in detail !
!------------------------------------------------------------------------!
L(255) = TRUE; ! Give DETAILED description !
gosub DESCRIBE;
STOP;
!------------------------------------------------------------------------!
:@INVOKE ! Invoke an object's magical properties
!------------------------------------------------------------------------!
! Called to use an an object in the current player's backpack. The
! action varies depending on the type of object. For example, food
! is consumed, potions, amulets, scrolls, etc. have their magical
! effect invoked.
gosub STILLKICKING;
if curritem.endgame = END_ON_USE then
if curritem.endtext > 0 then ! .. this text is displayed first.. !
readtext( curritem.endtext );
endif; ! .. then the game ends. !
ENDGAME;
endif;
if curritem.type = FOOD or curritem.type = POTION then
player.energy = 255; ! Not hungry any more..
gosub M1_INVOKE;
if curritem.type = POTION and curritem.count > 1 then
curritem.name = curritem.class;
endif;
dec( curritem.count );
elsif curritem.type = SCROLL or curritem.type = STAFF then
gosub M2_INVOKE;
elsif curritem.type = GEMS or curritem.type = RING or curritem.type = AMULET then
gosub M1_INVOKE;
if curritem.charges < 255 then
dec( curritem.charges );
if curritem.count > 1 then
curritem.name = curritem.class;
endif;
if curritem.type = GEMS and curritem.charges = 0 then
writeln( "The ", curritem.type, " vanishes after you use it." );
dec( curritem.count );
endif;
endif;
else
writeln( "The ", curritem.name, " has no magical properties.." );
endif;
STOP;
!------------------------------------------------------------------------!
!-- SCRIPT SUBROUTINES ARE GROUPED HERE AT THE END. THIS IS A CHOICE --!
!-- NOT A REQUIREMENT. IT MAKES THE MAIN SCRIPT CODE ABOVE A LITTLE --!
!-- BIT EASIER TO FOLLOW. ---------------------------------------------!
!------------------------------------------------------------------------!
!------------------------------------------------------------------------!
! STILLKICKING: Subroutine to verify that the player is alive before !
! allowing him/her/it to perform an action. !
!------------------------------------------------------------------------!
:STILLKICKING
if player.hp = 0 then
writeln( player.name, " is dead!" );
STOP;
endif;
RETURN;
!------------------------------------------------------------------------!
!
! SUBROUTINE: DESCRIBE
!
! This routine is invoked from @LOOK, @EXAMINE
!
!------------------------------------------------------------------------!
:DESCRIBE
!------------------------------------------------------------------------!
if curritem.count = 0 then
writeln( "DBG: Opps. There is nothing to look at in CURRITEM.SCR" );
STOP;
endif;
if curritem.picture >= 0 then
viewpcx( curritem );
if success then
pause;
endif;
paint(window); ! Assumes the picture fits in the window !
elsif curritem.type = SIGN or curritem.type = BOOK then
readtext( curritem.text );
STOP;
endif;
write( "You see a ", curritem.name );
if NOT L(255) then
writeln;
STOP;
endif;
write( ", Type: ", curritem.type );
!
! The following is a 'cascading if..then..elsif..elsif.....else..endif'
! statement. It is used here to illustrate it's usefulness. The same
! code could have been written with a 'ON curritem.type GOTO' statement.
!
if curritem.type = FOOD or curritem.type = POTION then
if curritem.class then
write( ", Class: ", curritem.class );
if curritem.class <> CURE then
write( ", Units: ", curritem.units );
endif;
endif;
elsif curritem.type = WEAPON then
write( ", Class: ", curritem.class,
", Hands: ", curritem.hands,
", Range: ", curritem.range,
", Damage: ", curritem.damage );
if curritem.ammoneeded then
write( ", Needs ammo type: ", curritem.ammo_type );
endif;
elsif curritem.type = AMMO then
write( ", Ammo Type: ", curritem.ammotype );
if curritem.traptype then
write( ", Poisoned" );
endif;
if curritem.damage then
write( ", Extra Damage: ", curritem.damage );
endif;
elsif curritem.type = ARMOR or curritem.type = SHIELD then
write( ", Armor Class: ", curritem.ac );
if curritem.cursed then
write( " Cursed!" );
endif;
elsif curritem.type = AMULET or curritem.type = RING or curritem.type = GEMS then
if curritem.class then
write( ", Class: ", curritem.class );
write( ", Charges: ", curritem.charges );
if curritem.class <> CURE then
write( ", Units: ", curritem.units );
if curritem.permanent then
write( ", Permanent!" );
else
write( ", Temporary" );
endif;
endif;
if curritem.cursed then
write( ", Cursed!" );
endif;
endif;
elsif curritem.type = SCROLL then
write( ", Class: ", curritem.class );
elsif curritem.type = STAFF then
write( ", Class: ", curritem.class, ", Charges: ", curritem.charges );
elsif curritem.type = CHEST then
if curritem.locktype then
write( ", Locked!" );
if curritem.traptype = 0 then
write( ", no traps" );
elsif curritem.traptype = 1 then
write( ", poison trap" );
else
write( ", bomb damage: ", curritem.traptype );
endif;
endif;
! elsif curritem.type = KEYS then
! nothing special about it
! elsif curritem.type = BOOK then
! nothing special about it
! elsif curritem.type = GOLDSACK then
! nothing special about it
! elsif curritem.type = TORCH then
! nothing special about it
! elsif curritem.type = LANTERN then
! nothing special about it
! elsif curritem.type = ROPE then
! nothing special about it
! elsif curritem.type = HOOKS then
! nothing special about it
! elsif curritem.type = MIRROR then
! nothing special about it
! elsif curritem.type = SIGN then
! nothing special about it
elsif curritem.type = VEHICLE then
write( ", Class: ", curritem.class );
! else
! user defined type?
endif;
if curritem.weight > 1 and curritem.weight < 256 then
write( ", Weight: ", curritem.weight );
endif;
writeln( "." );
return;
!------------------------------------------------------------------------!
!
! SUBROUTINE: M1_INVOKE
!
! Type 1 Magic - Affects the person invoking the magic..
!
! This portion of the script is invoked whenever an individual in the
! adventurer's group:
!
! a) Eats food that has a magical effect
! b) Drinks a potion with a magical effect
! c) Successfully wears a ring or an amulet with a magical effect
! d) Uses a GEM that has a magical effect.
!
! When invoked, PLAYER is the person that will be affected, and CURRITEM
! is the item that has the magical effect, and which is either being
! worn or in the character's backpack. OBJECT and NPC are not defined.
!
!------------------------------------------------------------------------!
:M1_INVOKE
!------------------------------------------------------------------------!
if curritem.cursed and curritem.permanent then
curritem.permanent = FALSE;
writeln( "WARNING: This object was 'cursed' and had 'permanent' effect!" );
writeln( "WARNING: The effect has been made 'temporary' by OBJECT.SCR" );
endif;
on curritem.class goto
M1_NONE, M1_CURE, M1_HEAL, M1_POISON, M1_RESTORE,
M1_STR, M1_DEX, M1_SPD, M1_AIM, M1_AC,
M1_HP, M1_IQ, M1_PWR;
:M1_NONE
writeln( "Nothing happens.." );
return;
:M1_CURE
if player.poisoned then
player.poisoned = 0;
writeln( player.name, " is now cured." );
else
writeln( "Nothing happens.." );
endif;
return;
:M1_HEAL
if player.hp >= player.mhp then
writeln( "Nothing happens.." );
elsif player.hp = 0 then
writeln( player.name, " is beyond help.." );
else
if curritem.units > 0 then
L(0) = curritem.units; ! always heals the same points !
else
L(0) = random(player.mhp - player.hp)+1; ! heal a random number of points !
endif;
voice( "Tada", 1000 );
if player.hp + L(0) < player.mhp then
writeln( player.name, " heals ", L(0), " hit points.." );
inc( player.hp, L(0) );
else
writeln( player.name, " has been completely healed!" );
player.hp = player.mhp;
endif;
endif;
return;
:M1_POISON
if NOT player.poisoned then
player.poisoned = 1;
voice( "Boing", 1000 );
writeln( "You feel sick.." );
else
voice( "Boing", 1000 );
writeln( "You feel worse.." );
endif;
return;
:M1_RESTORE
if player.hp >= player.mhp then
writeln( "Nothing happens.." );
elsif player.hp = 0 then
writeln( player.name, " is beyond help.." );
else
voice( "okspell", 1000 );
player.hp = player.mhp;
writeln( player.name, " is completely healed!" );
endif;
return;
:M1_STR
if curritem.cursed then
player.str = 0;
voice( "BOING", 1000 );
writeln( "Something went wrong.." );
else
voice( "okspell", 1000 );
inc( player.str, curritem.units );
if curritem.permanent then
inc( player.mstr, curritem.units );
endif;
writeln( player.name, "'s strength increased by ", curritem.units, "!" );
endif;
return;
:M1_DEX
if curritem.cursed then
player.dex = 0;
voice( "BOING", 1000 );
writeln( "Something went wrong.." );
else
voice( "okspell", 1000 );
inc( player.dex, curritem.units );
if curritem.permanent then
inc( player.mdex, curritem.units );
endif;
writeln( player.name, "'s dexterity increased by ", curritem.units, "!" );
endif;
return;
:M1_SPD
if curritem.cursed then
player.spd = 0;
voice( "BOING", 1000 );
writeln( "Something went wrong.." );
else
voice( "okspell", 1000 );
inc( player.spd, curritem.units );
if curritem.permanent then
inc( player.mspd, curritem.units );
endif;
writeln( player.name, "'s speed increased by ", curritem.units, "!" );
endif;
return;
:M1_AIM
if curritem.cursed then
player.aim = 0;
voice( "BOING", 1000 );
writeln( "Something went wrong.." );
else
voice( "okspell", 1000 );
inc( player.aim, curritem.units );
if curritem.permanent then
inc( player.maim, curritem.units );
endif;
writeln( player.name, "'s aim increased by ", curritem.units, "!" );
endif;
return;
:M1_AC
if curritem.cursed then
player.ac = 0;
voice( "BOING", 1000 );
writeln( "Something went wrong.." );
else
voice( "okspell", 1000 );
inc( player.ac, curritem.units );
if curritem.permanent then
inc( player.mac, curritem.units );
endif;
writeln( player.name, "'s armor class increased by ", curritem.units, "!" );
endif;
return;
:M1_HP
if curritem.cursed then
player.hp = player.hp / 3 + 1;
writeln( player.name, " has been seriously injured!" );
else
voice( "okspell", 1000 );
inc( player.hp, curritem.units );
if curritem.permanent then
inc( player.mhp, curritem.units );
endif;
writeln( player.name, "'s hit points increased by ", curritem.units, "!" );
endif;
return;
:M1_IQ
if curritem.cursed then
player.iq = 0;
voice( "BOING", 1000 );
writeln( "Something went wrong.." );
else
voice( "okspell", 1000 );
inc( player.iq, curritem.units );
if curritem.permanent then
inc( player.miq, curritem.units );
endif;
writeln( player.name, "'s i.q. increased by ", curritem.units, "!" );
endif;
return;
:M1_PWR
if player.class = ELF or player.class = WIZARD then
if curritem.cursed then
player.pwr = 0;
voice( "BOING", 1000 );
writeln( "Something went wrong.." );
else
inc( player.pwr, curritem.units );
if curritem.permanent then
inc( player.mpwr, curritem.units );
endif;
voice( "okspell", 1000 );
writeln( player.name, "'s power increased by ", curritem.units, "!" );
endif;
else
voice( "Argh", 1000 );
write( player.name, " screams and falls to the ground, " );
if player.hp < 3 then
writeln( "dead!" );
player.hp = 0;
else
writeln( "holding his head.." );
dec( player.hp, 2 );
endif;
endif;
return;
!------------------------------------------------------------------------!
!
! SUBROUTINE: M2_INVOKE
!
! Type 2 Magic - Affects an object or a another person
!
! This portion of the script handles magic spells which affect objects
! or persons other than the caster. When invoked, the PLAYER is the
! person that invoked the spell and CURRITEM is the object that was used
! to invoke the spell (which is either being worn or carried by the
! player).
!
! The OBJECT and NPC are undefined. If the spell requires a target,
! the 'LOCATE' function can be used to select an object or character
! to cast the spell on. The locate function returns the distance in blocks
! to the selected target. If none is selected, the value is -1, and FAILURE
! is set.
!
! After a LOCATE, either OBJECT or NPC will be set depending on whether the
! user selected an object or a character (or monster, during a fight).
!
! To figure out which one was selected, check if NPC.COUNT is greater than
! 0. If it is, a character was selected. If it is not, then an object was
! selected.
!
!------------------------------------------------------------------------!
:M2_INVOKE
!------------------------------------------------------------------------!
if curritem.class = NONE then
writeln( "Nothing happens.." );
return;
endif;
if curritem.count = 0 then
writeln( "Oops, no object in OBJECT.SCR, m2 invoke" );
stop;
endif;
if curritem.class = DAMAGE or curritem.class = CONFUSE or
curritem.class = SCARE or curritem.class = PARALYZE or
curritem.class = KILL then
if not fighting then
writeln( "This spell can only be used during a fight.." );
return;
endif;
!
! L(5) will contain the TOTAL experience points gained when done..
! L(6) is the maximum damage that will be done to a single monster..
! L(8) is the maximum total damage that can be done to a group of monsters..
! L(9) is the TOTAL number of monsters affected AFTER the spell
!
L(5) = 0;
L(6) = player.level + adjustments(player.pwr) / 2 + 1;
if L(6) <= 0 then
writeln( "The spell failed.." );
STOP;
endif;
if curritem.units then
L(8) = curritem.units;
else
L(8) = player.iq + adjustments(player.iq);
endif;
L(9) = 0;
endif;
if curritem.type = STAFF and curritem.charges = 0 then
writeln( "The ", curritem.name, " doesn't work.." );
return;
endif;
if curritem.class <> LEAVE and
curritem.class <> ZOOM and
curritem.class <> INFORM and
curritem.class <> DOORS and
curritem.class <> RESURRECT then
write( curritem.class, " what:" );
L(1) = locate; ! SETS THE TARGET FOR THE SPELL !
if L(1) = 0 then
writeln( "nothing.." );
return;
endif;
! Either NPC.COUNT or OBJECT.COUNT identifies selected object/char !
if npc.count then ! It's a character, not an object..
if npc.type = HOSTILE then
writeln( npc.name ); ! monster's don't have classes.. !
else
writeln( npc.class ); ! Human, elf, dwarf, etc.. !
endif;
if curritem.class = DESTROY or curritem.class = DUPLICATE or
curritem.class = RECHARGE or curritem.class = FLOAT then
writeln( "This spell only work's on objects!" );
goto M2_EXIT;
endif;
else
writeln( object.type ); ! Food, weapon, ring, etc.. !
endif;
endif;
on curritem.class goto
M2_EXIT, M2_DESTROY, M2_DUPLICATE, M2_LEAVE,
M2_RESURRECT,M2_INFORM, M2_LOCATE, M2_KILL,
M2_CONFUSE, M2_SCARE, M2_DAMAGE, M2_PARALYZE,
M2_RECHARGE, M2_FLOAT, M2_ANALYZE, M2_ZOOM;
:M2_NONE ! No magic..
writeln( "Nothing happens.." );
goto M2_EXIT;
:M2_DESTROY ! Destroy an object pwr = 5, rng=10
! if player.pwr < 5 goto M2_NOPOWER; ! No power check needed
if L(1) > 10 goto M2_OUTOFRANGE;
voice( "Explode", 1000 );
writeln( "The ", object.type, " is destroyed.." );
vanish( object );
L(4) = 5;
goto M2_EXIT;
:M2_DUPLICATE ! Duplicates an object pwr = 40, rng=1
! if player.pwr < 40 goto M2_NOPOWER; ! No power check needed
if L(1) > 1 goto M2_OUTOFRANGE;
inc( object.count, 1 ); ! Creates an identical copy !
L(4) = 40;
goto M2_EXIT;
:M2_LEAVE ! Exit through the 'exit' door from anywhere...
if world.type <> DUNGEON then
voice( "Boing", 1000 );
writeln( "This spell only work's in dungeons.." );
return;
endif;
! if player.pwr < 5 goto M2_NOPOWER; ! No power check needed
enter( world.edgedoor );
voice( "okspell", 1000 );
writeln( "You leave this level of the dungeon.." );
L(4) = 5;
goto M2_EXIT;
:M2_RESURRECT ! Revive a DEAD person pwr = 50, rng=1
! if player.pwr < 50 goto M2_NOPOWER; ! No power check needed
if L(1) > 1 goto M2_OUTOFRANGE;
write( "Resurrect: " );
L0 = select( group );
stats( L0 );
if player.hp > 0 then
voice( "Boing", 1000 );
writeln( "This player is NOT dead!" );
return;
endif;
voice( "okspell", 1000 );
writeln( player.name );
player.hp = 2;
writeln( player.name, " is alive, but weak.." );
L(4) = 50;
goto M2_EXIT;
:M2_INFORM ! Displays some text pwr = 5
! if player.pwr < 5 goto M2_NOPOWER; ! No power check needed
if L(1) > 5 goto M2_OUTOFRANGE;
loadhint;
writeln( "The wind seems to carry a random phrase to your ears.." );
writeln( s0 );
L(4) = 5;
goto M2_EXIT;
:M2_LOCATE ! Locate doors pwr = 10
! if player.pwr < 10 goto M2_NOPOWER; ! No power check needed
if L(1) > 10 goto M2_OUTOFRANGE;
L(0) = 0;
:LDLOOP
if world.doorx(L0) > 0 and world.doory(L0) > 0 then
frame( world.doorx(L0), world.doory(L0), SYS_FRAME );
endif;
inc(L0);
if L(0) < 16 goto LDLOOP;
L(4) = 10;
goto M2_EXIT;
:M2_KILL ! Kill 1 enemy during battle pwr = 20, rng=6
writeln( npc.name, " killed. +", npc.hp, " exp." );
inc( player.exp, npc.hp );
npc.count = 0;
STOP;
:M2_DAMAGE ! Causes damage to monsters pwr = 5, rng=12
S0 = "hit";
foreach npc do
L(7) = min( npc.hp, random(L6) ); ! How much damage to this one monster?
if L(7) > 0 then
frame(npc.x, npc.y, SYS_SPLAT); wait(1); frame(npc.x, npc.y, SYS_SPLAT);
write( npc.name );
if L(7) < npc.hp then
write( " hit." );
dec( npc.hp, L(7) ); ! Hit the monster..
else
write( " killed!" );
npc.count = 0;
endif;
writeln( " +", L(7), " exp." );
inc(L9); ! Count of affected npcs
inc( L(5), L(7) ); ! Accumulate experience..
if L(5) > L(8) goto DCSPEXIT; ! Stop when total of L(8) points used
endif;
endfor;
goto DCSPEXIT;
:M2_CONFUSE ! Makes monsters shoot at other monsters pwr = 1, rng=12
S0 = "confused";
foreach npc do
L(7) = min( npc.hp, random(L6) ); ! How much confusion to this one monster?
if L(7) > 0 and npc.confused = 0 then
frame(npc.x, npc.y, SYS_SPLAT); wait(1); frame(npc.x, npc.y, SYS_SPLAT);
inc(L9); ! Count of affected npcs
npc.confused = L(7); ! Confuse for 'n' units
inc( L(5), L(7) ); ! Accumulate experience..
if L(5) > L(8) goto DCSPEXIT; ! Stop when total of L(8) points used
endif;
endfor;
goto DCSPEXIT;
:M2_SCARE ! Scares monsters pwr = 2, rng=12
S0 = "scared";
foreach npc do
L(7) = min( npc.hp, random(L6) ); ! How much 'fright' to this one monster?
if L(7) > 0 and npc.scared = 0 then
frame(npc.x, npc.y, SYS_SPLAT); wait(1); frame(npc.x, npc.y, SYS_SPLAT);
inc(L9);
npc.scared = L(7); ! Frighten for 'n' units
inc( L(5), L(7) ); ! Accumulate experience..
if L(5) > L(8) goto DCSPEXIT; ! Stop when total of L(8) points used
endif;
endfor;
goto DCSPEXIT;
:M2_PARALYZE ! Monster can't move pwr = 5, rng=12
S0 = "paralyzed";
foreach npc do
L(7) = min( npc.hp, random(L6) ); ! How much paralysis to this one monster?
if L(7) > 0 and npc.paralyzed = 0 then
frame(npc.x, npc.y, SYS_SPLAT); wait(1); frame(npc.x, npc.y, SYS_SPLAT);
inc(L9);
npc.paralyzed = L(7); ! Paralyze for 'n' units
inc( L(5), L(7) ); ! Accumulate experience..
if L(5) > L(8) goto DCSPEXIT; ! Stop when total of L(8) points used
endif;
endfor;
goto DCSPEXIT;
:M2_RECHARGE ! Recharge an ITEM pwr = 25, rng=1
! if player.pwr < 25 goto M2_NOPOWER; ! No power check needed
if L(1) > 1 goto M2_OUTOFRANGE;
if object.type = RING or object.type = AMULET or object.type = STAFF then
inc( object.charges, random(player.level)+1 );
voice( "okspell", 1000 );
writeln( "The ", object.type, " now has ", object.charges, " charges." );
else
voice( "Boing", 1000 );
writeln( "The smell of rotten eggs fills the air.." );
endif;
L(4) = 25;
goto M2_EXIT;
:M2_FLOAT ! Remove an object's weight pwr = 10, rng=1
! if player.pwr < 10 goto M2_NOPOWER; ! No power check needed
if L(1) > 1 goto M2_OUTOFRANGE;
if object.weight < 255 then
object.weight = object.weight / 2 + 1;
voice( "okspell", 1000 );
writeln( "The ", object.type, " is now much lighter.." );
else
voice( "Boing", 1000 );
writeln( "It's didn't work. The ", object.type, " is too heavy." );
endif;
L(4) = 10;
goto M2_EXIT;
:M2_ANALYZE ! Discover object's properties pwr = 10, rng=1
! if player.pwr < 10 goto M2_NOPOWER; ! No power check needed
if L(1) > 1 goto M2_OUTOFRANGE;
L(255) = TRUE; ! Give DETAILED description !
gosub DESCRIBE;
L(4) = 10;
goto M2_EXIT;
:M2_ZOOM ! View the world..
! if player.pwr < 25 goto M2_NOPOWER; ! No power check needed
viewpcx( world );
if success then
pause;
endif;
paint( screen ); ! If you don't have any WORLD###.PCX files, you can use !
! paint( WINDOW ) instead of paint( SCREEN) !
L(4) = 25;
goto M2_EXIT;
:M2_NOPOWER
writeln( "You don't have enough power!" );
return;
:M2_OUTOFRANGE
writeln( "You are too far away from the ", object.name );
return;
:DCSPEXIT
if L(9) then
write( L(9), " foes were ", S0 );
if L(5) then
writeln( " for a total of +", L(5), " experience!" );
inc( player.exp, L(5) ); ! Grant experience..
else
writeln( " With no effect" );
endif;
else
writeln( "No effect.." );
endif;
goto M2_EXIT;
:M2_EXIT
if curritem.count > 0 then
if curritem.count > 1 then
curritem.name = curritem.class;
endif;
if curritem.type = SCROLL then
dec( curritem.count ); ! Item disapears if count reaches 0 !
elsif curritem.type = STAFF then
dec( curritem.charges ); ! One less !
endif;
else
dec( player.pwr, L(4) ); ! A spell !
endif;
return;
!------------------------------------------------------------------------!
:UNLOCK_OBJECT
!------------------------------------------------------------------------!
L0 = 0;
L1 = curritem.index;
L2 = curritem.locktype;
:UCLOOP
setbp( player, L0 );
if player.bp.count then
if player.bp.type = KEYS and player.bp.keytype = L2 then
write( "You use the ", player.bp.name, " to unlock the " );
setbp( player, L1 ); ! Recover the 'curritem' !
writeln( curritem.name );
curritem.locktype = 0;
if curritem.block2 then
L0 = curritem.block2;
curritem.block = curritem.block2;
curritem.block2 = L0;
endif;
return;
endif;
endif;
inc( L0 );
if L0 < 16 goto :UCLOOP;
RETURN;